{{! corresponding files: people_mailings.php & people_mailings.json }}
{{#connection_options}}
<header>
		<h4 class="page-title">{{copy_mass_mailing_title}}</h4>
		<h5 class="page-subtitle">{{copy_test_message}}</h5>

</header>
	<form method="post" action="/admin/people/mailings" id="mass_mailing">
		<input type="hidden" name="action" id="action" value="">
        <label for="mail_subject">{{label_mail_subject}}</label>
        <input class="required" type="text" id="mail_subject" name="mail_subject" value="{{subject}}"/>

		    <div class="pure-g">
			<div class="pure-u-1 pure-u-md-1-2">
				<label for="mail_from">{{{label_from_name}}} <strong>{{email_address}}</strong>)</label>
				<input class="required" type="text" id="mail_from" name="mail_from" value="{{mail_from}}"/>
			</div><!--pure-->
			<div class="pure-u-1 pure-u-md-1-2">

				<label for="template_id">{{label_use_template}}</label>
				<select id="template_id" name="template_id">
					<option value="default" selected="selected">{{copy_default}}</option>
					<option value="none">{{copy_no_template}}</option>
				</select>
			</div><!--pure-->
            </div>
			
			<div class="pure-g">
                <div class="pure-u-1 pure-u-md-1-3">
                    <label for="email_list_id">{{label_send_to_list}}</label>
                    <select id="email_list_id" name="email_list_id">
                        {{{options_people_lists}}}
                    </select>
                </div><!--pure-->

                <div class="pure-u-1 pure-u-md-1-3">
                    <label for="connection_id">{{label_use_mass}}</label>
                    <select id="connection_id" name="connection_id">
                        {{{connection_options}}}
                    </select>
                </div><!--pure-->

                <div class="pure-u-1 pure-u-md-1-3">
                    <label for="attached_asset">Attach asset</label>
                    <select id="attached_asset" name="attached_asset">
                        {{{asset_options}}}
                    </select>
                </div>
            </div>

				<label for="html_content">{{label_message}}<span class="tooltip" data-tooltip="The message will be formatted as HTML using Markdown, and added to a template. You can use HTML and Markdown to control content.">(markdown/html allowed)</span></label>
				<textarea class="required taller" rows="3" id="html_content" name="html_content">{{html_content}}</textarea>
			<div id="settings-drawer" class="drawer material pure-u-1">

	<h5 class="drawerhandle hide title"><div class="icon icon-airplane"></div><!--icon--><span>{{copy_test_message_title}}</span></h5>
	<div class="drawercontent">
					<div class="pure-u-1 pure-u-md-2-3">
					<label>{{{copy_test_label}}}</label>
						<input type="text" id="test_recipients" name="test_recipients" placeholder="your@email.com" value="{{test_recipients}}"/>
					</div><!--pure-->
					<div class="pure-u-1 pure-u-md-1-3">
						<label>&nbsp;</label>

						<button class="send_email fullwidth" type="submit" name="dotestsend"><div class="icon icon-list"></div><!--icon-->{{copy_send_test}}</button>
					</div><!--pure-->
	</div><!--drawercontent-->

</div><!--drawer prefpanel-->

<div class="pure-u-1">
			<button class="send_email" name="dolivesend" type="submit">{{copy_send_list}}</button>
			</div><!--pure-->

	</form>


{{/connection_options}}

{{^connection_options}}
<div class="alt callout usecolor3"><div class="callout-inner">
	<div class="pure-u-1 pure-u-md-1-2">
		<h3 class="firstuse-title">{{{copy_firstuse}}}</h3>
	</div>
	<div class="pure-u-1 pure-u-md-1-2">
		<div class="browser-header"><span></span><span></span><span></span></div><!--brower-header-->
		<img src="{{www_path}}/assets/images/firstuse/people_mailings_screen.jpg" alt="screenshot" />
	</div>
</div><!--callout-inner-->
</div><!--callout-->
<div class="material">
<p>{{copy_youll_need}}<a href="{{www_path}}/settings/connections/">{{copy_mass_mailing}}</a>{{copy_to_use}}</p></div>
{{/connection_options}}

<script>
    $(function() {

        $(".send_email").click(function(e) {

            var action = ($(this).attr('name') == "dolivesend") ? "dolivesend" : "dotestsend";
            $('#action').val(action);

            e.preventDefault(); //Prevent the normal submission action


            if ($("#test_recipients").val() != "" && action == 'dotestsend' || action == 'dolivesend') {
                $('#mass_mailing').submit();
            } else {
                $("#test_recipients").addClass("shake");
            }
        });

    });
</script>